<?php
session_start();
set_include_path(get_include_path() . PATH_SEPARATOR . '.' . PATH_SEPARATOR . './libs/');
require_once('./libs/Smarty/Smarty.class.php');
require_once('./libs/classes/dbconection.class.php');
require_once('./libs/classes/quzhuanyi.fun.php');
require_once('./libs/classes/UserModel.class.php');
require_once('./libs/classes/fenye.class.php');
require_once('Zend/Config/Xml.php');
$dbLink = dbconection::makealink();
$pageInfo = new Zend_Config_Xml('./config/config.xml','page');
$pageInfo= $pageInfo->toArray();
$perpage = $pageInfo['perpages'];
$ls = new Smarty();
if(isset($_SESSION['userinfo']))
{
	$pages = Fenye::count($_SESSION['userinfo']['id']);
	$pageLinks = Fenye::fenyelink($pages,$perpage);
	$ls->assign('links',$pageLinks);
	$ls->assign('username',$_SESSION['userinfo']['username']);
	$ls->assign('userage',$_SESSION['userinfo']['userage']);
	$ls->assign('userinfo',$_SESSION['userinfo']['userjianjie']);
	if(isset($_GET['p']))
	{
		$pianyi = ($_GET['p']-1)*$perpage;
		$logs = $dbLink->query("select * from article where article_uid={$_SESSION['userinfo']['id']} order by article_id desc limit $pianyi,$perpage");
	}else
	{
		$logs = $dbLink->query("select * from article where article_uid={$_SESSION['userinfo']['id']} order by article_id desc limit $perpage");
	}
	$rows = $logs->fetchAll();

	$rows =stripslashesx($rows);   //去\转意
	$ls->assign('logs',$rows);

	{
		/*
		 *查找用户设置 
		 */
		$custom = UserM::getUserDeploy($_SESSION['userinfo']['id']);
		$ls->assign('custom',$custom);
			
	}

	$ls->display('bca.html');
}else
{
	$userinfomation = $dbLink->fetchRow("select * from user where user_login='{$_GET['u']}'");
	//		$zuozheinfo = array('name'=>$userinfomation['user_name'],
	//											'age'=>$userinfomation['user_age'],
	//											'info'=>$userinfomation['user_info']);
	$ls->assign('info',$userinfomation);
	/*
	 * 分页部分
	 */
	$pages = Fenye::count($userinfomation['user_id']);
	$pageLinks = Fenye::fenyelink($pages,$perpage);
	$ls->assign('links',$pageLinks);
	if(isset($_GET['p']))
	{
		$pianyi = ($_GET['p']-1)*$perpage;
		$logs = $dbLink->query("select * from article where article_uid={$userinfomation['user_id']} order by article_id desc limit $pianyi,$perpage");
	}else
	{
		$logs = $dbLink->query("select * from article where article_uid={$userinfomation['user_id']} order by article_id desc limit $perpage");
	}
	$rows = $logs->fetchAll();
	$rows =stripslashesx($rows);   //去\转意
	$ls->assign('logs',$rows);

	{
		/*
		 *查找用户设置 
		 */
		$custom = UserM::getUserDeploy($userinfomation['user_id']);
		$ls->assign('custom',$custom);
			
	}
	$ls->display('abc.html');
}
?>